﻿using NUnit.Framework;
using RMH.DataAccess;
using RMH.Entities;
using RMH.Services;

namespace RMH.UnitTests.Services
{
    [TestFixture]
    public class StaffServicewhen_getting_by_username : base_automock_test
    {
        private Staff staff;
        private string userName = "ignu";

        public override void establish_context()
        {
            Mock<IStaffRepository>()
                .Setup(s => s.GetByUserName(userName))
                .Returns(new Staff {Id = 3});
        }

        public override void because()
        {
            staff = Create<StaffService>().GetByUserName(userName);
        }

        [Test]
        public void user_is_returned_from_repository()
        {
            staff.Id.ShouldBeGreaterThan(0);            
        }

    }
    [TestFixture]
    public class StayService_when_getting_a_stay_by_id : base_automock_test
    {
        private Stay stay = new Stay() { Id = 1 };
        private Stay returnedStay = new Stay() { Id = 1 };
        private int stayId = 1;
       

        public override void establish_context()
        {
            Mock<IStayService>()
                .Setup(s => s.Get(stayId))
                .Returns(returnedStay);
        }

        public override void because()
        {
            returnedStay = Create<IStayService>().Get(stayId);
        }

        [Test]
        public void returns_a_stay_from_the_respository()
        {
            returnedStay.ShouldEqual(stay);
        }

    }
}
